package com.miao.util.scheme;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by miao on 2015/4/10.
 */
public class ResultScheme {
    public static final int ACT_RESULT_SUCCESS = 0;

    public static final int ACT_RESULT_FAIL = -1;

    public static String transfer(String keyword) {
        keyword = StringUtils.replace(keyword, "\\", "\\\\");
        keyword = StringUtils.replace(keyword, "%", "\\%");
        keyword = StringUtils.replace(keyword, "_", "\\_");
        return keyword;
    }

    public static void main(String[] args) {
        System.out.print(transfer("%like"));
    }

    public static int[] splitToArray(String ids, String split) {
        String[] id = StringUtils.split(ids, split);
        int[] arr = new int[0];
        if ((id != null) && (id.length > 0)) {
            for (String i : id) {
                arr = ArrayUtils.add(arr, Integer.parseInt(i));
            }
        }
        return arr;
    }
}
